﻿namespace B13_Ex01_5
{
    public static class Program
    {
        public static void Main()
        {
            StringStats.Run();
            System.Console.WriteLine("Press enter to continue...");
            System.Console.ReadLine();
        }
    }

    static class StringStats
    {
        private static int m_NumOfLowerCase = 0, m_NumOfUpperCase = 0, m_NumOfSpaces = 0, m_NumOfDigits;

        public static void Run()
        {
            updateStringStats(getStringFromUser());
            printStats();
        }

        private static string getStringFromUser()
        {
            System.Console.WriteLine("Please enter a string: ");
            return System.Console.ReadLine();
        }

        private static void updateStringStats(string i_StringFromUser)
        {
            char[] stringInCharArray = i_StringFromUser.ToCharArray();

            m_NumOfDigits = stringInCharArray.Length;
            foreach (char CurrentChar in stringInCharArray)
            {
                if (CurrentChar >= 'a' && CurrentChar <= 'z')
                {
                    m_NumOfLowerCase++;
                }
                else if(CurrentChar >= 'A' && CurrentChar <= 'Z')
                {
                    m_NumOfUpperCase++;
                }
                else if (CurrentChar == ' ')
                {
                    m_NumOfSpaces++;
                }
            }
        }

        private static void printStats()
        {
            string stats = string.Format(
@"Stats:
=====
Lower Case in string: {0}
Upper Case in string: {1}
Length of string: {2}
Spaces in string: {3}",
            m_NumOfLowerCase, m_NumOfUpperCase, m_NumOfDigits, m_NumOfSpaces);
            System.Console.WriteLine(stats);
        }
    }
}
